package com.support.utils

import android.content.Context
import android.content.SharedPreferences

/**
 * Create： zhangjunfei 1/22/21 6:05 PM
 * 描述：
 */
object SPUtils {
    private lateinit var SP: SharedPreferences

    fun initSP(context: Context) {
        SP = context.getSharedPreferences("FlutterSharedPreferences", Context.MODE_PRIVATE)
    }

    /**
     * 存储字符串
     */
    fun putString(key: String, value: String?) {
        SP.edit().putString(key, value ?: "").apply()
    }

    /**
     * 获取字符串
     */
    fun getString(key: String): String {
        return SP.getString(key, "") ?: ""
    }

    /**
     * 存储布尔值
     */
    fun putBoolean(key: String, value: Boolean) {
        SP.edit().putBoolean(key, value).apply()
    }

    /**
     * 获取布尔值
     */
    fun getBoolean(key: String): Boolean {
        return SP.getBoolean(key, false)
    }

    /**
     * 获取整形
     */
    fun getLong(key: String): Long {
        return SP.getLong(key, -1)
    }
}